def searchMatrix(matrix, target):
    M, N = len(matrix), len(matrix[0])
    left, right = 0, M * N - 1
    while left <= right:
        mid = left + (right - left) // 2
        cur = matrix[mid // N][mid % N]
        if cur == target:
            return True
        elif cur < target:
            left = mid + 1
        else:
            right = mid - 1
    return False
s = input().split(" ")
n = int(s[0])
m = int(s[1])
target = int(s[2])
matrix = [None] * n
for i in range(n):
    matrix[i] = [int(x) for x in input().split(" ")]
print(searchMatrix(matrix, target))